﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;

namespace Maze
{
    public partial class MainWindow : Form
    {
        private Maze _maze;
        private MazeOptions _options;
        private Bitmap _bitmap;

        public MainWindow()
        {
            InitializeComponent();
            _options = new MazeOptions();
        }

        private void MainWindow_Load(object sender, EventArgs e)
        {
            propertyGrid.PropertySort = PropertySort.Categorized;
            propertyGrid.SelectedObject = _options;
        }
        
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            _bitmap = new Bitmap(_options.Rows * (_options.CellWidth) + 10,
                _options.Columns * (_options.CellWidth) + 10);

            Graphics _Graphics = Graphics.FromImage((Image)_bitmap);

            _maze = null;
            _Graphics.DrawRectangle(Pens.Blue, 5, 5, _options.Rows * _options.CellWidth,
                _options.Columns * _options.CellWidth);
            _maze = new Maze(_options.Rows, _options.Columns, _options.CellWidth);
            _maze.Draw(_Graphics);

            pbMaze.Image = (Image)_bitmap;
        }
    }
}
